package org.msfj.toilets.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

/**
 * @Description:
 * @Author: like
 * @Date: 2018-08-27 16:44
 * @Version: 1.0
 * @Created in idea by autoCode
 */
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketAutoConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/api/toilet/websocket")         //开启/websocket端点
                .setAllowedOrigins("*")         //允许跨域访问
                .withSockJS().setHeartbeatTime(5000)    //使用sockJS
                .setDisconnectDelay(3000).setStreamBytesLimit(512);
    }
}
